package tankWar;

public class Members
{

}

class Shot implements Runnable {
	int x, y, direct;
	int speed = 10;
	boolean isalive = true;
	public Shot(int x, int y, int direct) {
		super();
		this.x = x;
		this.y = y;
		this.direct = direct;
	}
	
	public void run() {
		while (isalive) {
			try {
				switch (direct) {
				case 0:
					y -= speed;
					break;
				case 1:
					y += speed;
					break;
				case 2:
					x -= speed;
					break;
				case 3:
					x += speed;
					break;
				default:
					break;
				}
				this.isOut();
				Thread.sleep(50);
			}
			catch(InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	private void isOut()
	{
		if (x > 400 || x < -10 || y > 500 || y < -10 ) 
		{
				isalive = false;
		}
	}
}